-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TYP: NDFrame.(loc|iloc|at|iat) #30690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
pandas/core/generic.py
Outdated
@@ -3179,6 +3179,481 @@ def to_csv( | |||
# ---------------------------------------------------------------------- | |||
# Fancy Indexing | |||
|
|||
@property |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so to avoid moving these multiple times, can you create a mix-in class where these are put (you can define this in pandas.core.indexing i think would be ok), then just include it in the classes for Series/DataFrame
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe better (as we are going to do this anyhow) is create
pandas/core/generic/indexing.py (and put the mxin there)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea with a Mixin. Why do you want to set it on DataFrame/Series directly? Seems simpler to just set it on NDFrame.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right that’s totally fine
7f8fe40
to
75ee396
Compare
15f337b
to
a6f7730
Compare
a6f7730
to
eda2ca6
Compare
thanks @topper-123 very nice |
Currently, the NDFrame indexers (.loc/.iloc/.at/.iat) are too complex set up to let mypy understand them. This PR makes their implementations understandable for mypy (and humans also maybe, the old imp. was a bit indirect so took som effort to understand).
One issue is that I - for the life of me - can't programatically set doc strings of properties and make mypy understand the properties' types at the same time. Python/mypy seem to demand that doc strings be set directly on the property if the type is to be understandable by mypy. E.g. Appender on a property is not supported by mypy. So I've set the doc string on the NDFrame properties, and reference them from the indexer classes instances. This makes the PR seem large, but it's mostly just moving the doc strings.